package edu.upf.Ilusio.Entities;

/*
 * This class was automatically generated with 
 * <a href="http://www.castor.org">Castor 0.9.7</a>, using an XML
 * Schema.
 * $Id$
 */

  //---------------------------------/
 //- Imported classes and packages -/
//---------------------------------/

import java.io.IOException;
import java.io.Reader;
import java.io.Serializable;
import java.io.Writer;
import java.util.ArrayList;
import java.util.Enumeration;
import org.exolab.castor.xml.MarshalException;
import org.exolab.castor.xml.Marshaller;
import org.exolab.castor.xml.Unmarshaller;
import org.exolab.castor.xml.ValidationException;
import org.xml.sax.ContentHandler;

/**
 * Class Pnews.
 * 
 * @version $Revision$ $Date$
 */
public class Pnews implements java.io.Serializable {


      //--------------------------/
     //- Class/Member Variables -/
    //--------------------------/

    /**
     * Field _title
     */
    private java.lang.String _title;

    /**
     * Field _pictureList
     */
    private java.util.ArrayList _pictureList;

    /**
     * Field _paragraphList
     */
    private java.util.ArrayList _paragraphList;


      //----------------/
     //- Constructors -/
    //----------------/

    public Pnews() 
     {
        super();
        _pictureList = new ArrayList();
        _paragraphList = new ArrayList();
    } //-- Pnews()


      //-----------/
     //- Methods -/
    //-----------/

    /**
     * Method addParagraph
     * 
     * 
     * 
     * @param vParagraph
     */
    public void addParagraph(java.lang.String vParagraph)
        throws java.lang.IndexOutOfBoundsException
    {
        _paragraphList.add(vParagraph);
    } //-- void addParagraph(java.lang.String) 

    /**
     * Method addParagraph
     * 
     * 
     * 
     * @param index
     * @param vParagraph
     */
    public void addParagraph(int index, java.lang.String vParagraph)
        throws java.lang.IndexOutOfBoundsException
    {
        _paragraphList.add(index, vParagraph);
    } //-- void addParagraph(int, java.lang.String) 

    /**
     * Method addPicture
     * 
     * 
     * 
     * @param vPicture
     */
    public void addPicture(long vPicture)
        throws java.lang.IndexOutOfBoundsException
    {
        _pictureList.add(new java.lang.Long(vPicture));
    } //-- void addPicture(long) 

    /**
     * Method addPicture
     * 
     * 
     * 
     * @param index
     * @param vPicture
     */
    public void addPicture(int index, long vPicture)
        throws java.lang.IndexOutOfBoundsException
    {
        _pictureList.add(index, new java.lang.Long(vPicture));
    } //-- void addPicture(int, long) 

    /**
     * Method clearParagraph
     * 
     */
    public void clearParagraph()
    {
        _paragraphList.clear();
    } //-- void clearParagraph() 

    /**
     * Method clearPicture
     * 
     */
    public void clearPicture()
    {
        _pictureList.clear();
    } //-- void clearPicture() 

    /**
     * Method enumerateParagraph
     * 
     * 
     * 
     * @return Enumeration
     */
    public java.util.Enumeration enumerateParagraph()
    {
        return new org.exolab.castor.util.IteratorEnumeration(_paragraphList.iterator());
    } //-- java.util.Enumeration enumerateParagraph() 

    /**
     * Method enumeratePicture
     * 
     * 
     * 
     * @return Enumeration
     */
    public java.util.Enumeration enumeratePicture()
    {
        return new org.exolab.castor.util.IteratorEnumeration(_pictureList.iterator());
    } //-- java.util.Enumeration enumeratePicture() 

    /**
     * Method getParagraph
     * 
     * 
     * 
     * @param index
     * @return String
     */
    public java.lang.String getParagraph(int index)
        throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _paragraphList.size())) {
            throw new IndexOutOfBoundsException();
        }
        
        return (String)_paragraphList.get(index);
    } //-- java.lang.String getParagraph(int) 

    /**
     * Method getParagraph
     * 
     * 
     * 
     * @return String
     */
    public java.lang.String[] getParagraph()
    {
        int size = _paragraphList.size();
        java.lang.String[] mArray = new java.lang.String[size];
        for (int index = 0; index < size; index++) {
            mArray[index] = (String)_paragraphList.get(index);
        }
        return mArray;
    } //-- java.lang.String[] getParagraph() 

    /**
     * Method getParagraphCount
     * 
     * 
     * 
     * @return int
     */
    public int getParagraphCount()
    {
        return _paragraphList.size();
    } //-- int getParagraphCount() 

    /**
     * Method getPicture
     * 
     * 
     * 
     * @param index
     * @return long
     */
    public long getPicture(int index)
        throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _pictureList.size())) {
            throw new IndexOutOfBoundsException();
        }
        
        return ((java.lang.Long)_pictureList.get(index)).longValue();
    } //-- long getPicture(int) 

    /**
     * Method getPicture
     * 
     * 
     * 
     * @return long
     */
    public long[] getPicture()
    {
        int size = _pictureList.size();
        long[] mArray = new long[size];
        for (int index = 0; index < size; index++) {
            mArray[index] = ((java.lang.Long)_pictureList.get(index)).longValue();
        }
        return mArray;
    } //-- long[] getPicture() 

    /**
     * Method getPictureCount
     * 
     * 
     * 
     * @return int
     */
    public int getPictureCount()
    {
        return _pictureList.size();
    } //-- int getPictureCount() 

    /**
     * Returns the value of field 'title'.
     * 
     * @return String
     * @return the value of field 'title'.
     */
    public java.lang.String getTitle()
    {
        return this._title;
    } //-- java.lang.String getTitle() 

    /**
     * Method isValid
     * 
     * 
     * 
     * @return boolean
     */
    public boolean isValid()
    {
        try {
            validate();
        }
        catch (org.exolab.castor.xml.ValidationException vex) {
            return false;
        }
        return true;
    } //-- boolean isValid() 

    /**
     * Method marshal
     * 
     * 
     * 
     * @param out
     */
    public void marshal(java.io.Writer out)
        throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
    {
        
        Marshaller.marshal(this, out);
    } //-- void marshal(java.io.Writer) 

    /**
     * Method marshal
     * 
     * 
     * 
     * @param handler
     */
    public void marshal(org.xml.sax.ContentHandler handler)
        throws java.io.IOException, org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
    {
        
        Marshaller.marshal(this, handler);
    } //-- void marshal(org.xml.sax.ContentHandler) 

    /**
     * Method removeParagraph
     * 
     * 
     * 
     * @param vParagraph
     * @return boolean
     */
    public boolean removeParagraph(java.lang.String vParagraph)
    {
        boolean removed = _paragraphList.remove(vParagraph);
        return removed;
    } //-- boolean removeParagraph(java.lang.String) 

    /**
     * Method removePicture
     * 
     * 
     * 
     * @param vPicture
     * @return boolean
     */
    public boolean removePicture(long vPicture)
    {
        boolean removed = _pictureList.remove(new java.lang.Long(vPicture));
        return removed;
    } //-- boolean removePicture(long) 

    /**
     * Method setParagraph
     * 
     * 
     * 
     * @param index
     * @param vParagraph
     */
    public void setParagraph(int index, java.lang.String vParagraph)
        throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _paragraphList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _paragraphList.set(index, vParagraph);
    } //-- void setParagraph(int, java.lang.String) 

    /**
     * Method setParagraph
     * 
     * 
     * 
     * @param paragraphArray
     */
    public void setParagraph(java.lang.String[] paragraphArray)
    {
        //-- copy array
        _paragraphList.clear();
        for (int i = 0; i < paragraphArray.length; i++) {
            _paragraphList.add(paragraphArray[i]);
        }
    } //-- void setParagraph(java.lang.String) 

    /**
     * Method setPicture
     * 
     * 
     * 
     * @param index
     * @param vPicture
     */
    public void setPicture(int index, long vPicture)
        throws java.lang.IndexOutOfBoundsException
    {
        //-- check bounds for index
        if ((index < 0) || (index > _pictureList.size())) {
            throw new IndexOutOfBoundsException();
        }
        _pictureList.set(index, new java.lang.Long(vPicture));
    } //-- void setPicture(int, long) 

    /**
     * Method setPicture
     * 
     * 
     * 
     * @param pictureArray
     */
    public void setPicture(long[] pictureArray)
    {
        //-- copy array
        _pictureList.clear();
        for (int i = 0; i < pictureArray.length; i++) {
            _pictureList.add(new java.lang.Long(pictureArray[i]));
        }
    } //-- void setPicture(long) 

    /**
     * Sets the value of field 'title'.
     * 
     * @param title the value of field 'title'.
     */
    public void setTitle(java.lang.String title)
    {
        this._title = title;
    } //-- void setTitle(java.lang.String) 

    /**
     * Method unmarshal
     * 
     * 
     * 
     * @param reader
     * @return Object
     */
    public static java.lang.Object unmarshal(java.io.Reader reader)
        throws org.exolab.castor.xml.MarshalException, org.exolab.castor.xml.ValidationException
    {
        return (Pnews) Unmarshaller.unmarshal(Pnews.class, reader);
    } //-- java.lang.Object unmarshal(java.io.Reader) 

    /**
     * Method validate
     * 
     */
    public void validate()
        throws org.exolab.castor.xml.ValidationException
    {
        org.exolab.castor.xml.Validator validator = new org.exolab.castor.xml.Validator();
        validator.validate(this);
    } //-- void validate() 

}
